package com.example.demo.service;


import com.example.demo.dao.TelInfoMapper;
import com.example.demo.dao.payrollStepRecordExpiresMapper;
import com.example.demo.dao.payrollStepRecordMapper;
import com.example.demo.dao.payrollRecordMapper;
import com.example.demo.dao.payrollMapper;
import com.example.demo.entity.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class insertService {

    @Resource
    private payrollStepRecordExpiresMapper payrollStepRecordExpiresMapper;
    @Resource
    private payrollStepRecordMapper payrollStepRecordMapper;
    @Resource
    private payrollRecordMapper payrollRecordMapper;
    @Resource
    private TelInfoMapper telInfoMapper;
    @Resource
    private payrollMapper payrollMapper;


    nameService name = new nameService();
    randomDataService rd = new randomDataService();

    private String oo;

    public void insertSql() {


        int rand = rd.randoNumber();



        if (rand == 1) {

            payroll p = new payroll();
            //工单编码

            oo = this.orderBm();
            p.setRoll_number(oo);
            p.setPayroll_result(rd.orderState());
            p.setPayroll_type(rd.payrollType());
            p.setRoll_content(rd.rollontent());
            p.setPayroll_name(name.getChineseName());
            p.setCompany_id(425954);
            p.setPhone("15670761931");
            //电话号码
            p.setCompany_tel(rd.phone());
            p.setDi_ids("2");
            p.setCard_number(name.getChineseName());
            p.setManager_id("175");
            p.setLast_ope_date("2020-09-21 09:05:45");
            p.setSrc_way("热线电话");
            p.setSex("男");
            p.setEvent_type(rd.scounte());
            //满意、不满意
            p.setService_attitude(rd.manyis());
            p.setService_attitude_detail("无");
            p.setJob_number("2001");
            p.setPayroll_src_tel_id("0");
            p.setExpires(315360000);
            //直办转办
            p.setHandle_type(rd.handleType());
            p.setPublic_flag(2);
            p.setDistribute_job_number("0");
            p.setDistribute_count(0);
            p.setRedistribute("否");
            p.setRedistribute_count(0);
            p.setDifficulty("否");
            p.setRoll_count(1);
            p.setDelay_status(0);
            p.setDelay("否");
            p.setDelay_count(0);
            p.setRefuse_status(0);
            p.setRefuse("否");
            p.setPhone_number("12329");
            p.setPublic_record(2);
            p.setUrge("否");
            p.setUrge_count(0);
            p.setSecret_flag(2);
            p.setPass_status("否");
            p.setNews_clue("否");
            p.setCallType(1);
            p.setRegion_ids("0");
            //姓名
            p.setUser_name(name.getChineseName());
            p.setOut_status("否");
            p.setFloor(1);
            p.setExpired(0);
            p.setExpire_time("2030-05-13 00:05:45");
            p.setP_rest_num(0);
            p.setView_flag(1);
            p.setAdd_di_id(2);
            p.setModule_name("系统默认");
            p.setRecord_pass_status(-1);
            p.setPs_caption("受理阶段");
            p.setP_pss_caption("待受理");
            p.setEvent_type2_1_id(0);
            p.setEvent_type2_2_id(0);
            p.setEvent_type2_3_id(0);
            p.setEvent_type2_4_id(0);
            p.setLongitude("0");
            p.setLatitude("0");
            p.setOne_no("0");
            p.setTo_of_time_c(0);
            p.setTo_of_time(0);
            p.setSecret_info("否");
            p.setHandle_di_id(rd.scounte());
            p.setCancel("否");
            p.setCancel_count(0);
            p.setBack_to_p("否");
            p.setBack_to_p_count(0);
            p.setApp_id("0");
            p.setDate("2020-09-19 09:05:45");
            p.setIs_push(0);
            p.setMore_return_flag(2);
            p.setDis_app_id("0");
//            p.setRole_id(0);
            p.setWiki_title(0);
            //区域
            p.setRegion_district_id(rd.scountd());

            Integer insert = payrollMapper.insert(p);
            System.out.println(insert + "----");
        } else if (rand == 2) {

            TelInfo telInfo = new TelInfo();

            telInfo.setTel_id(5000);
            telInfo.setSrc_tel_id("1111111111");
            telInfo.setUi_id(294);
            telInfo.setJob_number("1005");
            telInfo.setSp_id(3);
            telInfo.setCompany_id(626152);
            telInfo.setOneNo("86795925");
            //电话号码
            telInfo.setTelerNo(rd.phone());
            telInfo.setToPhone("8205");
            telInfo.setRecfile("D:///");
            telInfo.setRecsort("1");
            telInfo.setCallType(1);
            telInfo.setStarttime(rd.starttimes());
            telInfo.setEndtime(rd.endtime());
            telInfo.setCallTime(98);
            telInfo.setIn_type(0);
            telInfo.setStatus(0);
            telInfo.setTalked(1);
            telInfo.setOut_key_number(2);
            telInfo.setIn_key_number(-1);
            telInfo.setParent_tel_id(0);
            telInfo.setRebuild_flag(0);
            telInfo.setRebuild_cause(0);
            telInfo.setChild_tel_id(0);
            telInfo.setUser_no("8205");
            telInfo.setPhone_number("12329");
            telInfo.setRecfile_ori("1005/2020-8/31/8679592520200831235922_15180718916.wav");
            telInfo.setUser_name("罗扬");
            telInfo.setCallcenter_ip("10.10.14.11");
            telInfo.setOrder_number(null);
            telInfo.setOrder_type(0);
            telInfo.setCardno(null);
            telInfo.setFee(0.00);
            telInfo.setDi_id(4);
            telInfo.setPass_status(-1);
            telInfo.setSecret_flag(0);
            telInfo.setCall_trying_time("2020-09-21 09:05:45");
            telInfo.setCall_rel_time("2020-09-21 09:05:45");
            telInfo.setCall_connected_time("2020-09-21 09:05:45");
            telInfo.setCall_rel_time("2020-09-21 09:07:45");
            telInfo.setQueue_start_time("2020-09-21 09:07:45");
            telInfo.setQueue_end_time("2020-09-21 09:07:45");
            telInfo.setCallee_call_trying_time("2020-09-21 09:07:45");
            telInfo.setCallee_call_ring_time("2020-09-21 09:07:45");
            telInfo.setCallee_call_connected_time("2020-09-21 09:07:45");
            telInfo.setCallee_call_rel_time("2020-09-21 09:07:45");
            telInfo.setRel_flag(2);
            telInfo.setMissing_order(1);
            telInfo.setMan_start_time("2020-09-21 09:07:45");
            telInfo.setRec_content_in(null);
            telInfo.setRec_content_out(null);
            telInfo.setRec_content(null);
            telInfo.setService_attitude_detail_key(-1);
            telInfo.setGet_user_no_time("2020-09-21 09:07:45");
            telInfo.setHandle_start_time("2020-09-21 09:07:45");
            telInfo.setMax_handle_time(0);
            telInfo.setHandle_end_time("2020-09-21 09:07:45");
            telInfo.setRebot_to_man(2);
            telInfo.setRebot_flag(2);
            telInfo.setApp_id(null);
            telInfo.setIs_push(0);
//            telInfo.setP_id(5339);
            telInfo.setP_roll_number(oo);
            Integer insert = telInfoMapper.insert(telInfo);
            System.out.println(insert + "---------");

        } else if (rand == 3) {
            payrollRecord pr = new payrollRecord();
            pr.setDate("2020-09-21 09:07:45");
            pr.setNote("0");
            pr.setOpper("黄莉");
            pr.setNumber("2005152001001");
            pr.setDi_ids("2");
            pr.setAdd_di_id(0);
            pr.setSrc_di_id(0);
//            pr.setFlag(0);
            pr.setHandle_level(1);
            pr.setIsMoreReturn("否");
            pr.setIsRefuse("否");
            pr.setExpires(2);
            pr.setPass(0);
            pr.setRel_id(0);
            pr.setPayroll_resulttmp("待受理");
            pr.setJob_number("2001");
            pr.setPhone_number("12329");
            pr.setPs_caption("受理阶段");
            pr.setPso_caption("保存");
            pr.setPsre_id(3);
            pr.setPayroll_result("待受理");
            pr.setPs_caption_a("受理阶段");
            pr.setO_flag(1);
            pr.setLast_status_flag(1);
            pr.setIsView(2);
            pr.setNote10("100");
            pr.setIs_push(0);
//            pr.setExpire_time_units("0");
            pr.setDelay_flag(0);
            pr.setDelay_return_flag(0);
            pr.setRefuse_flag(0);
            pr.setRefuse_return_flag(0);
            pr.setSupervise_flag(0);
            pr.setDelay_num(0);
            pr.setUrge_flag(0);
            pr.setRefuse_num(0);
            pr.setInspect_flag(0);
            pr.setInspect_return_flag(0);
            pr.setSing_flag(0);
            pr.setConsult_flag(0);
            pr.setConsult_return_flag(0);
            pr.setConsult_num(0);

            Integer insert = payrollRecordMapper.insert(pr);

            System.out.println(insert + "-----");
        } else if (rand == 4) {
            payrollStepRecord psr = new payrollStepRecord();

            psr.setDate("2020-09-21 09:07:45");
            psr.setNote("测试");
            psr.setOpper("高欣");
            psr.setNumber("2006242994001");
            psr.setDistribute_way("网上转办");
            psr.setDi_ids("9");
//            psr.setFlag(99);
            psr.setHandle_level(1);
            psr.setIsMoreReturn("否");
            psr.setIsRefuse("否");
            psr.setExpires(2);
            psr.setPass(0);
            psr.setRel_id(0);
            psr.setJob_number("2994");
            psr.setPhone_number("12329");
            psr.setExpire_time("2020-09-21 09:07:45");
            psr.setModule_name("立案阶段");
            psr.setPso_caption("确定");
            psr.setPsot_name("退回受理");
            psr.setAdd_di_id(9);
            psr.setSrc_di_id(0);
            psr.setIs_push(0);
            psr.setExpire_time_units("1");

            Integer insert = payrollStepRecordMapper.insert(psr);

            System.out.println(insert + "----------");

        } else if (rand == 5) {
            payrollStepRecordExpires psre = new payrollStepRecordExpires();
            psre.setPsre_number("2008252996010_005");
            psre.setPsre_ps_caption("受理阶段");
            psre.setPhone_number("12329");
            psre.setPsre_expires(315360000);
            psre.setPsre_pss_caption_time("2020-09-21 09:07:45");
            psre.setPsre_pss_caption_end_time("2020-09-21 09:07:45");
            psre.setPsre_expire_time("2020-09-21 09:07:45");
//            psre.setFlag(1);
            psre.setIs_push(1);

            Integer insert = payrollStepRecordExpiresMapper.insert(psre);
            System.out.println(insert + "----------");
        }
    }

    //2009198005018

    private static int abc = 8005018;

    public String orderBm() {

        StringBuffer sb = new StringBuffer();


//        int abc = 2001160;
        abc++;
        String s = String.valueOf(abc);
        sb.append("200919");
        sb.append(s);

        String toString = sb.toString();
        return toString;
    }

}
